1ead89ce7e663244f27983be80fdffedb2e01647,opennms-provision/opennms-detector-lineoriented/src/main/java/org/opennms/netmgt/provision/detector/simple/response/MultilineHttpResponse.java,MultilineHttpResponse,validateResponse,#String#String#boolean#number#,61

Before Change


     * @throws java.lang.Exception if any.
     */
    public boolean validateResponse(final String pattern, final String url, final boolean isCheckCode, final int maxRetCode) throws Exception {
        final String[] codeArray = Integer.toString(maxRetCode).split("");
        if(codeArray.length < 3) {
            throw new Exception("Max Ret Code is too Short");
        }
        final String httpResponse = (String)getResponseList().toArray()[0];

        final Pattern p;
        if (isCheckCode) {
            p = Pattern.compile(String.format("([H][T][T][P+]/[1].[0-1]) ([0-%s][0-2][0-%s]) ([a-zA-Z ]+)\r\n", codeArray[1], codeArray[3]));
        } else {
            p = DEFAULT_REGEX;
        }

        final Matcher m = p.matcher(httpResponse);
        if (m.matches()) {
            return getResponseListAsString(getResponseList().toArray()).contains(pattern);
        }
        
        return false;
    }
    
    /**

After Change


     * @return a boolean.
     * @throws java.lang.Exception if any.
     */
    public boolean validateResponse(final String pattern, final String url, final boolean isCheckCode, final int maxRetCode) throws Exception {
        final String httpResponse = (String)getResponseList().toArray()[0];
        LOG.debug("HTTP Response: {}", httpResponse);
        final Matcher m = HTTP_RESPONSE_REGEX.matcher(httpResponse);
        if (m.matches()) {
            if (isCheckCode) {
                final int returnCode = Integer.valueOf(m.group(2)).intValue();
                LOG.debug("return code = {}, max return code = {}", returnCode, maxRetCode);
                return (returnCode <= maxRetCode);
            } else {
                return true;
            }
        } else {
            LOG.debug("does not match");
            return false;
        }
    }